// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import './styles/index.scss'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.config.productionTip = false


// 添加全局导航守卫--全局路由守卫
// 自动调用
router.beforeEach((to, from, next) => {
  var token = localStorage.getItem('mytoken')

  // console.log(token);
  if(token)
  {
      next()
  }
  else
  {
      
      if(to.path === '/Login')
      {
           next()
      }
      else
      {
       
        next({name:'Login'})
      }
  }
 
})


Vue.use(ElementUI)
new Vue({
  el: '#app',
  router,
  components: {
    App
  },
  template: '<App/>'
})
